package com.fj.mockitotest.demos.web;

import com.fj.mockitotest.demos.service.UserService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author fj
 * @date 2025/8/13 13:51
 */
@RestController
@RequestMapping(value = "user")
public class UserController {

    private UserService userService;

    public UserController(UserService userService) {
        this.userService = userService;
    }

    @GetMapping(value = "getUserName/{id}")
    public String getUserName(@PathVariable int id) {
        String userName = userService.getUserName(id);
        if (userName == null) {
            return "用户不存在";
        }
        return userName;
    }
}
